{include file="common/index_header"/}
<style>
    .login_ad {
        width: 66%;
        margin: auto auto 25px auto;
        color: #ef841a;
        text-align: center;
        font-weight: 500;
        padding: 10px 0px;
        float: left;
        border-bottom: 2px solid #ef841a;
    }
</style>
</head>
<div class="login">
    <div class="imgs" style="background: url(__STATIC__/lib/index_new/images/fimg2.jpg) no-repeat center/cover;">
        <h3>More flexibility to control your business expenses with BetterEpay cards</h3>
    </div>
    <div class="lts">
        <div class="text">
            <form action="" method="post" class="layui-form">
                <div class="ico"><img src="__STATIC__/lib/index_new/images/logo.png" ></div>
                <div class="login_ad">ACCOUNT INFORMATION VALIDATION</div>
                <div class="tet">
                    <div class="ic"><img src="__STATIC__/lib/index_new/images/fc17.png" ></div>
                    <input type="text" class="t" name="username" id="username" lay-verify="required_en|email_en" lay-verType="tips" placeholder="your email address."/>
                </div>
                <div class="clearfix fclae">
                    <div class="tet">
                        <div class="ic"><img src="__STATIC__/lib/index_new/images/fc19.png" ></div>
                        <input type="text" class="t" name="vercode" id="vercode" maxlength="6" placeholder="verification code"/>
                    </div>
                    <a href="#" id="getsmscode">Send Code</a>
                </div>
                <input class="sub" type="button" value="Confirm" lay-submit lay-filter="login" />
                <div class="dont">
                    <h5>Existing accounts?<a href="{:url('login/login')}">Log' In</a></h5>
                </div>
            </form>
        </div>
    </div>
</div>
<body>
<script>
    layui.config({
        base: '__STATIC__/lib/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function() {
        var $ = layui.$,
            form = layui.form;

        $('#vercode').val('');

        form.render();

        //提交
        form.on('submit(login)', function(data) {
            JsPost("{:url('login/resetPwd')}", data.field, function(data){
                if (data.code > 0) {
                    layer.msg("Email verification successful.", {icon:16,time:1500});
                    setTimeout("window.location.href='" +  "{:url('login/pwdChange')}" + "'; ", 1000);
                } else {
                    layer.msg(data.msg , {icon:16,time:1500});
                }
            });
            return false;
        });

        var getCode = document.getElementById('getsmscode');
        var wait = 60;
        function time(btn){
            if (wait===0) {
                getCode.removeAttribute("disabled");
                getCode.innerHTML = "Send Code";
                wait = 60;
            }else{
                getCode.setAttribute("disabled",true);
                getCode.innerHTML = "<font color='black'>" + wait + " </font> Resend after";
                wait--;
                setTimeout(function(){
                    time(btn);
                },1000);
            }
        }
        getCode.onclick = function(){
            const username = $("#username").val();

            if(!username){
                layer.msg('Email cannot be blank.',{icon: 16, time: 1500});
                $("#username").focus();
                return false;
            }

            const loading =parent.layer.load(1, {shade: [0.1,'#fff']});
            $.post("{:url('login/emailSend')}", {username:username,send_type:'check_pwd'}, function (res) {
                parent.layer.close(loading);
                if (res.code > 0) {
                    time(this);
                    layer.msg('The verification code has been sent, please wait patiently.', {time: 1500, icon: 16});
                } else {
                    layer.msg(res.msg,{icon: 16, time: 1500});
                }
            });
        };
    });
</script>
{include file="common/index_footer"/}